package jmu.zzh.alumnus.user.controller;

import jmu.zzh.alumnus.common.response.R;
import jmu.zzh.alumnus.user.entity.Class;
import jmu.zzh.alumnus.user.entity.College;
import jmu.zzh.alumnus.user.entity.Major;
import jmu.zzh.alumnus.user.service.SchoolInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("school")
public class SchoolInfoController {

    @Autowired
    private SchoolInfoService schoolInfoService;

    @GetMapping("/all-colleges")
    public R<List<College>> getAllColleges() {
        return R.ok(schoolInfoService.getAllColleges());
    }

    @GetMapping("/all-majors")
    public R<List<Major>> getAllMajors() {
        return R.ok(schoolInfoService.getAllMajors());
    }

    @GetMapping("/all-classes")
    public R<List<Class>> getAllClasses() {
        return R.ok(schoolInfoService.getAllClasses());
    }

    @GetMapping("/colleges")
    public R<List<College>> getColleges(@RequestParam Integer year) {
        return R.ok(schoolInfoService.getCollegesByYear(year));
    }

    @GetMapping("/majors")
    public R<List<Major>> getMajors(@RequestParam String collegeCode, @RequestParam Integer year) {
        return R.ok(schoolInfoService.getMajorsByCollegeAndYear(collegeCode, year));
    }

    @GetMapping("/classes")
    public R<List<Class>> getClasses(@RequestParam String collegeCode, @RequestParam Integer year) {
        return R.ok(schoolInfoService.getClassesByCollegeAndYear(collegeCode, year));
    }
} 